package com.fc.test.api;

import com.fc.test.service.TAbbTixianService;
import com.fc.test.service.TAbbWithdrawService;
import com.fc.test.util.JsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value = "apiWithdrawController")
@Api(value = "提现")
public class ApiWithdrawController {

    @Autowired
    private TAbbWithdrawService withdrawService;

    @Autowired
    private TAbbTixianService tixianService;

    @ResponseBody
    @PostMapping(value="applyWithdraw",produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "申请提现")
    public String applyWithdraw(
            @ApiParam(value = "用户id") @RequestParam(value = "userid") String userid,
            @ApiParam(value = "提现金额") @RequestParam(value = "totalmoney") double totalmoney,
            @ApiParam(value = "支付宝账号") @RequestParam(value = "alipayAccount") String alipayAccount
    ){
        Map<String,Object> resMap = withdrawService.applyWithdraw(userid,totalmoney,alipayAccount);
        return JsonUtil.jsonMapStr(resMap);
    }

    @ResponseBody
    @PostMapping(value="getTixianbili",produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "获取提现手续费比例")
    public String getTixianbili(
            @ApiParam(value = "用户id") @RequestParam(value = "userid") String userid
    ){
        Map<String,Object> resMap = withdrawService.getTixianbili(userid);
        return JsonUtil.jsonMapStr(resMap);
    }
}
